    #test.search.2.rb - Search Test
    #Description 
    #This is to test the search   functionality .
    require 'watir'
    include Watir    
    require 'test/unit'
    require '../watir.config.rb'

  class TC_BasicSearch_test < Test::Unit::TestCase 
      def startup
        @@ie = Watir::IE.start($SITE_URL)
      end
    
      def ie
        if defined? @@ie
          @@ie
        else
          startup
        end
      end
      
      def test_01_verifyHomePage 
        assert(ie.contains_text(/Community Server/))	
      end
      
      def test_02_verifySearchBox    
        assert(ie.text_field(:id, /TitleBarSearchText$/).exists?)
      end
      
      def test_03_verifySearchLink
        assert(ie.button(:id, /TitleBarSearchButton$/).exists?)
      end
      
      def test_04_enterSampleSearch
        ie.text_field(:id, /TitleBarSearchText$/).value = "sample"
        assert(ie.text_field(:id, /TitleBarSearchText$/).verify_contains("sample"))
      end
      
      def test_05_clickSearchLink
        ie.button(:id, /TitleBarSearchButton$/).click
        assert(ie.contains_text("You searched for the word(s): sample"))
      end
      
      def test_06_verifyLinksOnSearchResultsPage
        assert(ie.link(:text, 'Home').exists?)
        assert(ie.link(:text, 'Blogs').exists?)
        assert(ie.link(:text, 'Forums').exists?)
        assert(ie.link(:text, 'Photos').exists?)
        assert(ie.link(:text, 'Downloads').exists?)
        assert(ie.link(:text, 'Control Panel').exists?)
        assert(ie.link(:text, 'More Search Options').exists?)
      end
      
      def test_07_verifyFieldsOnSearchResultsPage
        assert(ie.button(:id, /SearchButtonTop$/).exists?)
        assert(ie.button(:id, /SearchButtonBottom$/).exists?)
        assert(ie.text_field(:id, /TitleBarSearchText$/).exists?)
        assert(ie.text_field(:id, /SearchTextTop$/).exists?)
        assert(ie.text_field(:id, /SearchTextBottom$/).exists?)
      end
      
      def test_99_closeIE
        ie.close
      end
    end
